﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "GbmpModel.h"
#include "DbDataSchema.h"
#include "IGraphicsNodeGroup.h"
#include "IParameter.h"

namespace gcmp 
{
    class GBMP_MODEL_EXPORT ILevelHeaderBehavior : public IDbObject
    {
        DEFINE_CAST_DERIVED(gcmp::ILevelHeaderBehavior, gcmp::IDbObject)
    public:
        virtual OwnerPtr<IGraphicsNodeGroup> CreateLevelHeader(const Vector3d& symbolPos, const Vector3d& symbolDir, const Vector3d& texDir, double height, double viewScale) const = 0;

    public:
        /// \brief 通过参数id来获得原生参数，此参数id文档唯一。
        /// \param parameterId 文档唯一的参数id
        /// \return Parameter 返回Parameter对象，如果失败则返回Parameter::InvalidParameter。
        virtual OwnerPtr<IParameter> GetNativeParameter(int parameterId) const = 0;

        /// \brief 设置原生参数
        /// 如果Element有原生参数（Native Parameter），该类需定制SetNativeParameter方法。
        /// \param parameter 输入要设置的参数对象
        /// \param errorMessage 输出错误信息，为可选参数。失败的情况下获取错误信息。
        /// \return bool 返回true表示设置成功，否则表示设置失败。如果失败可以通过errorMessage参数获取错误信息。
        virtual bool SetNativeParameter(const IParameter *parameter, std::wstring* errorMessage = nullptr) = 0;

        /// \brief 报告原生参数
        /// \param parameterIds Element拥有的原生参数
        /// \return void
        virtual void ReportParameterDefinitions(std::vector<int>* parameterIds) const = 0;

        /// \brief 获取参数是否可以被修改
        /// \param parameterId 文档唯一的参数id
        /// \return bool 如果参数可被修改，返回true。否则返回false。
        virtual bool IsParameterModifiable(int parameterId) const = 0;

    public:
        /// \brief 设置该行为所属Element
        /// \param pOwnerElement 所属Element
        /// \return bool
        virtual bool SetOwnerElement(IElement* pOwnerElement) = 0;

        /// \brief 获得该行为所属的Element
        /// \return 所属的Element
        virtual IElement* GetOwnerElement() = 0;

        /// \brief 获得该行为所属的Element
        /// \return 所属的Element
        virtual const IElement* GetOwnerElement() const = 0;
    };

}// namespace gcmp
